// package-store/pages/store-earning-detail/index.js
const app = getApp();
import { ManageTargetInfoUpdateMixins } from '../../../behaviors/page';
import { ACCOUNT_LOG_CATEGORY } from '../../../constants/common';
import { PACKAGE_ORDER_PAGE } from '../../../constants/route';
import { navTo } from '../../../common/env';

Page({
    mixins: [ManageTargetInfoUpdateMixins],
    data: {
        ACCOUNT_LOG_CATEGORY,
        recordInfo: {},
    },
    onLoad(options) {
        app.event.addListener('sendAccountLogInfo', this._handleDetail.bind(this));
    },
    onUnload() {
        app.event.removeListener('sendAccountLogInfo');
    },
    _handleDetail(recordInfo) {
        this.setData({
            recordInfo,
        });
    },
    handleNavToOrder() {
        const { orderSerialNumber } = this.data.recordInfo.extInfo;
        navTo(PACKAGE_ORDER_PAGE['storeOrderDetail'], {
            orderNumber: orderSerialNumber,
        });
    },
    handleNavToAfterSaleOrder() {
        const { afterSaleSerialNumber } = this.data.recordInfo.extInfo;
        navTo(PACKAGE_ORDER_PAGE['storeAfterSaleDetail'], {
            orderNumber: afterSaleSerialNumber,
        });
    },
})
